<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>父窗体</title>
        
        <script>
            
if(window.showModalDialog == undefined){ window.showModalDialog = function(url,mixedVar,features){ 
window.hasOpenWindow = true; 
debugger
if(mixedVar) window.mixedVar = mixedVar; //var mixedVar
if(features) var features = features.replace(/(dialog)|(px)/ig,"").replace(/;/g,',').replace(/\:/g,"="); 
window.myNewWindow = window.open(url,"_blank",features); 
} } ;           
        function openChild_nogood()
        {
             var o={a:'it-s a',b:12}; //获取父窗体的组件
             var win=window.open('./subwin.html');
             win.father_obj=o;//传给子窗口的对象
             console.log(win.father_obj);
        }
        function openChild_ie()
        {
            var MyArgs={a:'it-s a',b:12}; //获取父窗体的组件
            console.log(MyArgs.toString());
            debugger              
            var WinSettings = "center:yes;resizable:no;dialogHeight:300px";
            //谷歌浏览器不支持showModalDialog
            var returnValue = window.showModalDialog("./subwin.html", MyArgs, WinSettings);
            if (returnValue == null)
            {
                returnValue = window.returnValue;
                if (returnValue == null){
                window.alert("Nothing returned from child. No changes made to input boxes")
                } else{
                   console.log(returnValue); 
                }
            }
            else
            {
                console.log(returnValue.toString());
            debugger              
                var divsub=document.getElementById("divsub");
                divsub.htmlText = returnValue.toString();
            }

        }
        
        function openChildx2()
        {
            var MyArgs={a:'it-s a',b:12}; //获取父窗体的组件
            console.log(MyArgs.toString());
            debugger              
            var WinSettings = "center:yes;modal:true;resizable:no;dialogHeight:300px";
            //谷歌浏览器不支持showModalDialog
            var RetArgs = window.open("./subwin.html", MyArgs, WinSettings);
            if (RetArgs == null)
            {
                window.alert("Nothing returned from child. No changes made to input boxes")
            }
            else
            {
                console.log(RetArgs.toString());
            debugger              
                var divsub=document.getElementById("divsub");
                divsub.innerText = RetArgs.returnValue.toString();
            }

        }
        
        function openChild()
        {
            openChild_ie()
        }
        
        
        function getChildData(obj){
                var divsub=document.getElementById("divsub");
                divsub.innerText = window.toString();
          
        }
        </script>
                
	</head>
	<body>
        <div>
            这是父窗体<br/>
            测试<br/>
            <input type="button" value="打开子窗体" onclick="openChild()"><br/>
            子窗体返回的对象：<br/>
            <div id="divsub" style="border:solid thin red">还没有</div>
            <input type="button" value="取子窗体对象" onclick="getChildData()">
	    </div>
	</body>
</html>
